package com.jason.campusinn.view;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.Toast;

import com.yuandian.wanna.R;

/**
 * Created by yuandian on 2015/5/19.
 */
public class CustomerServicePopupWindow extends PopupWindow implements View.OnClickListener {

    private Button btn_call;

    private Button btn_cancel;

    private View view;

    private Context context;

    public CustomerServicePopupWindow(Context context){
        this.context=context;

        //初始化页面
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.customers_service, null);
        btn_call=(Button)view.findViewById(R.id.btn_customer_service_call);
        btn_cancel=(Button)view.findViewById(R.id.btn_customer_service_cancel);
        btn_call.setOnClickListener(this);
        btn_cancel.setOnClickListener(this);
        setContentView(view);

        // 设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        // 设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        // 设置SelectPicPopupWindow弹出窗体动画效果
        this.setAnimationStyle(R.style.popupStyle);
        // 实例化一个ColorDrawable颜色为半透明
//        ColorDrawable dw = new ColorDrawable(0xB0FFFFFF);
        // 设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(new ColorDrawable());
        this.setOutsideTouchable(true);
        this.update();

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_customer_service_call:
                Toast.makeText(context,"联系客服",Toast.LENGTH_LONG).show();
                break;
            case R.id.btn_customer_service_cancel:
                dismiss();
                break;
        }
    }
}
